HAL FDCAN types migration

This section provides information about the HAL FDCAN types migration.

HAL FDCAN callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_FDCAN_TX_FIFO_EMPTY_CB_ID,
  HAL_FDCAN_RX_BUFFER_NEW_MSG_CB_ID,
  HAL_FDCAN_HIGH_PRIO_MESSAGE_CB_ID,
  HAL_FDCAN_TIMESTAMP_WRAPAROUND_CB_ID,
  HAL_FDCAN_TIMEOUT_OCCURRED_CB_ID,
  HAL_FDCAN_ERROR_CALLBACK_CB_ID,
  HAL_FDCAN_MSPINIT_CB_ID,
  HAL_FDCAN_MSPDEINIT_CB_ID

} HAL_FDCAN_CallbackIDTypeDef;

Removed

Note

The callback registration in HAL2 is handled by specific functions for each FDCAN event. See HAL FDCAN register callbacks functions for more details.

HAL_FDCAN_MSPDEINIT_CB_ID and HAL_FDCAN_MSPINIT_CB_ID are removed because the functions HAL_FDCAN_MspInit() and HAL_FDCAN_MspDeInit() are removed.

Related concepts:


HAL FDCAN state type definition

Note

Use HAL_FDCAN_EnterPowerDownMode() to transition the peripheral into the HAL_FDCAN_STATE_POWER_DOWN state, and HAL_FDCAN_ExitPowerDownMode() to return it to the active state.

HAL1

HAL2

typedef enum
{
  HAL_FDCAN_STATE_RESET

  HAL_FDCAN_STATE_READY
  HAL_FDCAN_STATE_BUSY
  HAL_FDCAN_STATE_ERROR

} HAL_FDCAN_StateTypeDef;
typedef enum
{
  HAL_FDCAN_STATE_RESET
  HAL_FDCAN_STATE_INIT
  HAL_FDCAN_STATE_IDLE
  HAL_FDCAN_STATE_ACTIVE

  HAL_FDCAN_STATE_POWER_DOWN
} hal_fdcan_state_t;

Related concept: Revised and optimized HAL state machine


HAL FDCAN clock calibration unit type definition

The ClockCalibration and ClockDivider fields have been removed from the structure in HAL2. Instead, their functionality is handled by the independent functions HAL_FDCAN_CCU_SetClockRouting() and HAL_FDCAN_SetClockDivider(). For more detailed information, see Use case: Clock calibration (polling)

HAL1

HAL2

typedef struct
{

  uint32_t ClockCalibration;
  uint32_t ClockDivider;
  uint32_t TimeQuantaPerBitTime;
  uint32_t CalFieldLength;
  uint32_t MinOscClkPeriods;
  uint32_t WatchdogStartValue;
} FDCAN_ClkCalUnitTypeDef;
typedef struct
{
  /* ClockCalibration and ClockDivider fields have been removed. */
  Use HAL_FDCAN_CCU_SetClockRouting() to configure clock routing.
  Use HAL_FDCAN_SetClockDivider() to configure clock division.
  uint32_t                                  time_quanta_per_bit_time;
  hal_fdcan_ccu_field_length_t              calibration_field_length;
  uint32_t                                  min_osc_clk_periods;
  uint32_t                                  watchdog_start_value;
} hal_fdcan_ccu_config_t;

HAL FDCAN error counters type definition

HAL1

HAL2

typedef struct
{
  uint32_t TxErrorCnt;
  uint32_t RxErrorCnt;
  uint32_t RxErrorPassive;
  uint32_t ErrorLogging;
} FDCAN_ErrorCountersTypeDef;
typedef struct
{
  uint32_t                           tx_error_cnt;
  uint32_t                           rx_error_cnt;
  hal_fdcan_rx_error_passive_level_t rx_error_passive_status;
  uint32_t                           global_cnt;
} hal_fdcan_error_counters_t;

HAL FDCAN filter type definition

HAL1

HAL2

typedef struct
{
  uint32_t IdType;
  uint32_t FilterIndex;
  uint32_t FilterType;
  uint32_t FilterConfig;
  uint32_t FilterID1;
  uint32_t FilterID2;
  uint32_t RxBufferIndex;
  uint32_t IsCalibrationMsg;
} FDCAN_FilterTypeDef;
typedef struct
{
  hal_fdcan_id_type_t       id_type;
  uint32_t                  filter_index;
  hal_fdcan_filter_type_t   filter_type;
  hal_fdcan_filter_config_t filter_config;
  uint32_t                  filter_id1;
  uint32_t                  filter_id2;
  hal_fdcan_rx_location_t   rx_buffer_index;
  hal_fdcan_message_type_t  message_type;
} hal_fdcan_filter_t;

HAL FDCAN handle type definition

HAL1

HAL2

FDCAN_HandleTypeDef;
hal_fdcan_handle_t

Related concepts:


HAL FDCAN high priority message status type definition

HAL1

HAL2

typedef struct
{
  uint32_t FilterList;
  uint32_t FilterIndex;
  uint32_t MessageStorage;
  uint32_t MessageIndex;
} FDCAN_HpMsgStatusTypeDef;
typedef struct
{
  hal_fdcan_high_prio_filter_list_t     filter_list;
  uint32_t                              filter_index;
  hal_fdcan_high_prio_message_storage_t message_location_status;
  uint32_t                              message_index;
} hal_fdcan_high_prio_msg_status_t;

HAL FDCAN initialization type definition

The FDCAN_InitTypeDef structure contains common configuration elements used across STM32 series. In some series, the ClockDivider field is included directly in this structure; for details Use case: Initialization, configuration and filter configuration. In other series, ClockDivider is part of the FDCAN_ClkCalUnitTypeDef structure, while other configuration elements available; for details see Use case: Clock calibration (polling).

HAL1

HAL2

typedef struct
{
  uint32_t FrameFormat;
  uint32_t Mode;
  FunctionalState AutoRetransmission;
  FunctionalState TransmitPause;
  FunctionalState ProtocolException;



  uint32_t NominalPrescaler;
  uint32_t NominalSyncJumpWidth;
  uint32_t NominalTimeSeg1;
  uint32_t NominalTimeSeg2;





  uint32_t DataPrescaler;
  uint32_t DataSyncJumpWidth;
  uint32_t DataTimeSeg1;
  uint32_t DataTimeSeg2;


  uint32_t StdFiltersNbr;
  uint32_t ExtFiltersNbr;
  uint32_t TxFifoQueueMode;
  /* If ClockDivider is available here in the Init structure. */
  uint32_t ClockDivider;
  /* Else, ClockDivider is configured separately in FDCAN_ClkCalUnitTypeDef. */
  uint32_t MessageRAMOffset;
  uint32_t RxFifo0ElmtsNbr;
  uint32_t RxFifo0ElmtSize;
  uint32_t RxFifo1ElmtsNbr;
  uint32_t RxFifo1ElmtSize;
  uint32_t RxBuffersNbr;
  uint32_t RxBufferSize;
  uint32_t TxEventsNbr;
  uint32_t TxBuffersNbr;
  uint32_t TxFifoQueueElmtsNbr;
  uint32_t TxElmtSize;
} FDCAN_InitTypeDef;
typedef struct
{
  hal_fdcan_frame_format_t               frame_format;
  hal_fdcan_mode_t                       mode;
  hal_fdcan_auto_retransmission_status_t auto_retransmission;
  hal_fdcan_transmit_pause_status_t      transmit_pause;
  hal_fdcan_protocol_exception_status_t  protocol_exception;
  hal_fdcan_nominal_bit_timing_t         nominal_bit_timing;
  typedef struct
  {
    uint32_t nominal_prescaler;
    uint32_t nominal_jump_width;
    uint32_t nominal_time_seg1;
    uint32_t nominal_time_seg2;
  } hal_fdcan_nominal_bit_timing_t;

  hal_fdcan_data_bit_timing_t            data_bit_timing;
  typedef struct
  {
    uint32_t data_prescaler;
    uint32_t data_jump_width;
    uint32_t data_time_seg1;
    uint32_t data_time_seg2;
  } hal_fdcan_data_bit_timing_t;

  uint32_t                               std_filters_nbr;
  uint32_t                               ext_filters_nbr;
  hal_fdcan_tx_mode_t                    tx_fifo_queue_mode;

  Use HAL_FDCAN_SetClockDivider() to configure clock division.


  uint32_t                               message_ram_offset;
  uint32_t                               rx_fifo0_elt_nbr;
  hal_fdcan_data_field_size_t            rx_fifo0_elt_size;
  uint32_t                               rx_fifo1_elt_nbr;
  hal_fdcan_data_field_size_t            rx_fifo1_elt_size;
  uint32_t                               rx_buffer_nbr;
  hal_fdcan_data_field_size_t            rx_buffer_size;
  uint32_t                               tx_event_nbr;
  uint32_t                               tx_buffer_nbr;
  uint32_t                               tx_fifo_queue_elem_nbr;
  hal_fdcan_data_field_size_t            tx_fifo_queue_elem_size;
} hal_fdcan_config_t;

HAL FDCAN message RAM blocks type definition

HAL1

HAL2

typedef struct
{
  uint32_t StandardFilterSA;
  uint32_t ExtendedFilterSA;
  uint32_t RxFIFO0SA;
  uint32_t RxFIFO1SA;
  uint32_t RxBufferSA;
  uint32_t TxEventFIFOSA;
  uint32_t TxBufferSA;
  uint32_t TxFIFOQSA;
  uint32_t TTMemorySA;
  uint32_t EndAddress;
} FDCAN_MsgRamAddressTypeDef;
typedef struct
{
  uint32_t std_filter_start_addr;
  uint32_t ext_filter_start_addr;
  uint32_t rx_fifo0_start_addr;
  uint32_t rx_fifo1_start_addr;
  uint32_t rx_buffer_start_addr;
  uint32_t tx_event_start_addr;
  uint32_t tx_buffer_start_addr;
  uint32_t tx_fifo_start_addr;
  Removed: TTCAN not supported in HAL2
  uint32_t allocated_end_ram_addr;
} hal_fdcan_msg_ram_address_t;

HAL FDCAN protocol status type definition

HAL1

HAL2

typedef struct
{
  uint32_t LastErrorCode;
  uint32_t DataLastErrorCode;
  uint32_t Activity;
  uint32_t ErrorPassive;
  uint32_t Warning;
  uint32_t BusOff;
  uint32_t RxESIflag;
  uint32_t RxBRSflag;
  uint32_t RxFDFflag;
  uint32_t ProtocolException;
  uint32_t TDCvalue;
} FDCAN_ProtocolStatusTypeDef;
typedef struct
{
  hal_fdcan_protocol_error_code_t      last_error_code;
  hal_fdcan_protocol_error_code_t      data_last_error_code;
  hal_fdcan_communication_state_t      activity;
  hal_fdcan_protocol_error_status_t    error_status;
  hal_fdcan_warning_status_t           error_warning;
  hal_fdcan_bus_off_status_t           bus_off;
  hal_fdcan_esi_flag_status_t          rx_esi_flag;
  hal_fdcan_brs_flag_status_t          rx_brs_flag;
  hal_fdcan_edl_flag_status_t          rx_fdf_flag;
  hal_fdcan_protocol_exception_event_t protocol_exception;
  uint32_t                             tdc_value;
} hal_fdcan_protocol_status_t;

HAL FDCAN Rx header type definition

HAL1

HAL2

typedef struct
{



  uint32_t Identifier;
  uint32_t RxFrameType;
  uint32_t IdType;
  uint32_t ErrorStateIndicator;
  uint32_t RxTimestamp;
  uint32_t DataLength;
  uint32_t BitRateSwitch;
  uint32_t FDFormat;

  uint32_t FilterIndex;
  uint32_t IsFilterMatchingFrame;

} FDCAN_RxHeaderTypeDef;
typedef union
{
  uint64_t d64;
  struct
  {
    uint32_t                          identifier            : 29;
    hal_fdcan_frame_type_t            frame_type            : 1;
    hal_fdcan_id_type_t               identifier_type       : 1;
    hal_fdcan_error_state_indicator_t error_state_indicator : 1;
    uint32_t                          rx_timestamp          : 16;
    hal_fdcan_data_length_code_t      data_length           : 4;
    hal_fdcan_bit_rate_switch_t       bit_rate_switch       : 1;
    hal_fdcan_header_frame_format_t   frame_format          : 1;
    uint32_t                                                : 2;
    uint32_t                          filter_index          : 7;
    hal_fdcan_rx_frame_status_t       frame_status          : 1;
   } b;
} hal_fdcan_rx_header_t;

HAL FDCAN Tx event FIFO type definition

HAL1

HAL2

typedef struct
{



  uint32_t Identifier;
  uint32_t TxFrameType;
  uint32_t IdType;
  uint32_t ErrorStateIndicator;
  uint32_t TxTimestamp;
  uint32_t DataLength;
  uint32_t BitRateSwitch;
  uint32_t FDFormat;
  uint32_t EventType;
  uint32_t MessageMarker;

} FDCAN_TxEventFifoTypeDef;
typedef union
{
  uint64_t d64;
  struct
  {
    uint32_t                          identifier            : 29;
    hal_fdcan_frame_type_t            frame_type            : 1;
    hal_fdcan_id_type_t               identifier_type       : 1;
    hal_fdcan_error_state_indicator_t error_state_indicator : 1;
    uint32_t                          tx_timestamp          : 16;
    hal_fdcan_data_length_code_t      data_length           : 4;
    hal_fdcan_bit_rate_switch_t       bit_rate_switch       : 1;
    hal_fdcan_header_frame_format_t   frame_format          : 1;
    hal_fdcan_tx_event_type_t         event_type            : 2;
    uint32_t                          message_marker        : 8;
  } b;
} hal_fdcan_tx_evt_fifo_header_t;

HAL FDCAN Tx header type definition

HAL1

HAL2

typedef struct
{



  uint32_t Identifier;
  uint32_t TxFrameType;
  uint32_t IdType;
  uint32_t ErrorStateIndicator;

  uint32_t DataLength;
  uint32_t BitRateSwitch;
  uint32_t FDFormat;

  uint32_t TxEventFifoControl;
  uint32_t MessageMarker;

} FDCAN_TxHeaderTypeDef;
typedef union
{
  uint64_t d64;
  struct
  {
    uint32_t                          identifier                 : 29;
    hal_fdcan_frame_type_t            frame_type                 : 1;
    hal_fdcan_id_type_t               identifier_type            : 1;
    hal_fdcan_error_state_indicator_t error_state_indicator      : 1;
    uint32_t                                                     : 16;
    hal_fdcan_data_length_code_t      data_length                : 4;
    hal_fdcan_bit_rate_switch_t       bit_rate_switch            : 1;
    hal_fdcan_header_frame_format_t   frame_format               : 1;
    uint32_t                                                     : 1;
    hal_fdcan_tx_event_fifo_t         event_fifo_control         : 1;
    uint32_t                          message_marker             : 8;
  } b;
} hal_fdcan_tx_header_t;

HAL FDCAN TT operation status type definition

HAL1

HAL2

typedef FDCAN_TTOperationStatusTypeDef;
Removed: TTCAN not supported in HAL2

HAL FDCAN TT configuration type definition

HAL1

HAL2

typedef FDCAN_TT_ConfigTypeDef;
Removed: TTCAN not supported in HAL2

HAL FDCAN trigger type definition

HAL1

HAL2

typedef FDCAN_TriggerTypeDef;
Removed: TTCAN not supported in HAL2